package com.xhx.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xhx.db.entity.AppVersion;
import com.xhx.db.service.AppVersionService;
import com.xhx.vo.PageInfoParam;
import com.xhx.vo.PageInfoResult;

import lombok.extern.slf4j.Slf4j;

/**
 * app版本
 * 
 * @author xhx
 */
@Slf4j
@RequestMapping("/appVersion")
@RestController
public class AppVersionController {
	@Autowired
	private AppVersionService appVersionService;

	/**
	 * 获取
	 * 
	 * @param id
	 * @return
	 */
	@GetMapping("/{id}")
	public AppVersion getById(@PathVariable Long id) {
		return this.appVersionService.getById(id);
	}

	/**
	 * 添加
	 * 
	 * @param entity
	 * @return
	 */
	@PutMapping("/add")
	public int add(@RequestBody AppVersion entity) {
		return this.appVersionService.add(entity);
	}

	/**
	 * 逻辑删除
	 * 
	 * @param id
	 * @return
	 */
	@DeleteMapping("/{id}")
	public int deleteByIdFalse(@PathVariable Long id) {
		return this.appVersionService.deleteByIdFalse(id);
	}

	/**
	 * 更新
	 * 
	 * @param AppVersion
	 * @return
	 */
	@PutMapping("/update")
	public int updateById(@RequestBody AppVersion appVersion) {
		return this.appVersionService.updateById(appVersion);
	}

	/**
	 * 获取最新app版本
	 * 
	 * @param systemType
	 * @return
	 */
	@GetMapping("/new/{systemType}")
	public AppVersion getNewVersion(byte systemType) {
		return this.appVersionService.getNewVersion(systemType);
	}

	/**
	 * 通过版本号获
	 * 
	 * @param versionNo
	 * @return
	 */
	@GetMapping("/no/{versionNo}")
	public AppVersion getByNo(Integer versionNo) {
		return this.appVersionService.getByNo(versionNo);
	}

	/**
	 * 分页查询
	 * 
	 * @param param
	 * @return
	 */
	@PostMapping("/page")
	public PageInfoResult<AppVersion> getPage(@RequestBody PageInfoParam<Map<String, Object>> param) {
		return this.appVersionService.getPage(param);
	}

}
